import React, { Component } from "react";
import { Button, Select, Table, Input } from "antd";
import "./index.less";
const { Option } = Select;

// rowSelection object indicates the need for row selection
const rowSelection = {
  onChange: (selectedRowKeys, selectedRows) => {
    console.log(
      `selectedRowKeys: ${selectedRowKeys}`,
      "selectedRows: ",
      selectedRows
    );
  },
  getCheckboxProps: record => ({
    disabled: record.name === "Disabled User", // Column configuration not to be checked
    name: record.name
  })
};
function handleChange(value) {
  console.log(`selected ${value}`);
}

export default class ManagerHome extends Component {
  editorconpon = () => {
    this.props.history.push("/conpon/add");
  };
  columns = [
    {
      title: "优惠券名称",
      dataIndex: "name",
      render: text => <a>{text}</a>
    },
    {
      title: "类型",
      dataIndex: "age"
    },
    {
      title: "优惠内容",
      // dataIndex: "address"
      render: data => <div>{data.address}</div>
    },
    {
      title: "已领取/剩余",
      render: data => (
        <span className="those-responsible">
          <div className="main">子账号</div>
        </span>
      )
    },
    {
      title: "有效期",
      dataIndex: "age"
    },
    {
      title: "支付金额(元)",
      dataIndex: "age"
    },
    {
      title: "客单价(元)",
      dataIndex: "age"
    },
    {
      title: "状态 | 操作",
      align: "right",
      render: data => (
        <div className="status-operat">
          <span>暂停</span>
          <span className="editor" onClick={this.editorconpon}>
            修改
          </span>
          <span>删除</span>
        </div>
      )
    }
  ];
  data = [
    {
      key: "1",
      name: "John Brown",
      age: 32,
      address: "New York No. 1 Lake Park",
      mainRole: 0
    },
    {
      key: "2",
      name: "Jim Green",
      age: 42,
      address: "London No. 1 Lake Park",
      mainRole: 1
    },
    {
      key: "3",
      name: "Joe Black",
      age: 32,
      address: "Sidney No. 1 Lake Park",
      mainRole: 1
    },
    {
      key: "4",
      name: "Disabled User",
      age: 99,
      address: "Sidney No. 1 Lake Park",
      mainRole: 1
    }
  ];
  render() {
    return (
      <div className="manager-home">
        <div>
          <Button type="primary">新建优惠券</Button>
        </div>
        <div className="select">
          <span>优惠券名称：</span>
          <Input style={{ width: 180 }} placeholder="请输入优惠券名称" />
          <span className="spca">优惠券状态：</span>
          <Select
            defaultValue="lucy"
            style={{ width: 180 }}
            onChange={handleChange}
          >
            <Option value="jack">Jack</Option>
            <Option value="lucy">Lucy</Option>
            <Option value="Yiminghe">yiminghe</Option>
          </Select>
          <span className="spca">优惠券类型：</span>
          <Select
            defaultValue="lucy"
            style={{ width: 180 }}
            onChange={handleChange}
          >
            <Option value="jack">Jack</Option>
            <Option value="lucy">Lucy</Option>
            <Option value="Yiminghe">yiminghe</Option>
          </Select>
          <div className="filter">
            <Button type="primary">筛选</Button>
            <span className="conditions">清空筛选条件</span>
          </div>
        </div>
        <div className="filter-table">
          <Table
            rowSelection={this.rowSelection}
            columns={this.columns}
            dataSource={this.data}
            // bordered
          />
        </div>
      </div>
    );
  }
}
